<template>
	<view class="mysell">
		<!-- 左边绑定两栏 -->
		<view class="lef" style="width: 100vw;background-color: #fff;position: sticky;z-index: 9999;"
			:style="{top:systemHeight + 'px'}">
			<view class="back">
				<view class="sendorbuy">
					<view :class="{'mysend':true,'active':sendorbuy}" @click="sendor">
						我发布的
					</view>
					<view :class="{ 'mybuy':true,'active':!sendorbuy}" @click="buyor">
						我购买的
					</view>
				</view>
			</view>
			<view v-if="sendorbuy" class="">
				<!-- tab切换 -->
				<view class="tabs">
					<u-tabs :list="kinds" :activeStyle="{
			        color: '#333333',
			        fontWeight: '1000',
			    }" :inactiveStyle="{
			        color: '#999999',
			    }" lineColor='#FF7803' lineWidth='32rpx' lineHeight='8rpx' :current="current" @change="change">
						></u-tabs>
					<view class="controlall" @click="operateAll">
						{{edit?'取消操作':'批量操作'}}
					</view>
				</view>
			</view>
			<view v-else class="">
				<!-- tab切换 -->
				<view class="buytabs">
					<u-tabs itemStyle="padding-left: 54rpx; padding-right: 54rpx; height: 34px;" :list="buykinds" :activeStyle="{
			        color: '#333333',
			        fontWeight: '1000',
			    }" :inactiveStyle="{
			        color: '#999999',
			    }" lineColor='#FF7803' lineWidth='32rpx' lineHeight='8rpx' :current="current" @change="change">
						></u-tabs>
				</view>
			</view>
		</view>

		<!-- 我发布的 -->
		<view v-if="sendorbuy">
			<!-- 发布中 -->
			<view class="goods-cards" v-if="current===0">
				<!-- 商品卡片 -->
				<view class="card-item" v-for="(item,index) in activityBoxList" :key="index">
					<view class="card-bottom">
						<view class="rig" @click="changeitemChecked(item,index,iindex)" v-if="isedit">
							<uni-icons :type="item.ischeck?'checkbox-filled':'circle'" size="20"
								:color="item.ischeck?'#54AEFA':'#D0D0D0'" class="way-right">
							</uni-icons>
						</view>
						<!-- 卡片左侧 -->
						<view class="card-lef">
							<image class="card-img" :src="item.image" mode="aspectFill" />
						</view>
						<!-- 卡片右侧 -->
						<view class="card-rig">
							<view class="good-name" :class="{'good-checked':isedit}">
								{{item.boxName}}
							</view>
							<view class="good-details">
								<view class="btn" v-if="!isedit">
									下架
								</view>
								<view class="goodstatus">
									<text>￥{{pricerange.preprice}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 已成交 -->
			<view class="goods-cards" v-if="current===1">
				<!-- 商品卡片 -->
				<view class="card-item" v-for="(item,index) in buyBoxList" :key="index">
					<view class="card-top">
						<view class="info">
							<image :src="item.src" mode="aspectFill" />
							<view class="name">
								{{item.user}}
							</view>
						</view>

					</view>
					<view class="card-bottom">
						<view class="rig" @click="changeitemChecked(item,index,iindex)" v-if="iseditSec">
							<uni-icons :type="item.ischeck?'checkbox-filled':'circle'" size="20"
								:color="item.ischeck?'#54AEFA':'#D0D0D0'" class="way-right">
							</uni-icons>
						</view>
						<!-- 卡片左侧 -->
						<view class="card-lef">
							<image class="card-img" :src="item.image" mode="aspectFill" />
						</view>
						<!-- 卡片右侧 -->
						<view class="card-rig">
							<view class="good-name" :class="{'good-checked':iseditSec}">
								{{item.boxName}}
							</view>

							<view class="good-details">
								<view class="btn delbtn">
									删除订单
								</view>
								<view class="goodstatus">
									<text class="sellnum" style="font-size: 28rpx;">出售价:</text>
									<text>￥{{pricerange.preprice}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
			<!-- 已下架 -->
			<view class="goods-cards" v-if="current==2">
				<!-- 商品卡片 -->
				<view class="card-item card-long" v-for="(item,index) in buyBoxList" :key="index">
					<view class="card-bottom">
						<view class="rig" @click="changeitemChecked(item,index,iindex)" v-if="iseditThi">
							<uni-icons :type="item.ischeck?'checkbox-filled':'circle'" size="20"
								:color="item.ischeck?'#54AEFA':'#D0D0D0'" class="way-right">
							</uni-icons>
						</view>
						<!-- 卡片左侧 -->
						<view class="card-lef">
							<image class="card-img" :src="item.image" mode="aspectFill" />
						</view>
						<!-- 卡片右侧 -->
						<view class="card-rig card-long">
							<view class="good-name" :class="{'good-checked':iseditThi}">
								{{item.boxName}}
							</view>
							<view class="good-details">
								<view class="goodstatus">
									<text class="sellnum" style="font-size: 24rpx;">出售价</text>
									<input class="priceinp" :value="pricerange.preprice" type="text">
								</view>
							</view>

						</view>
					</view>
					<view class="good-details">
						<view class="btn specBtn">
							上架
						</view>
						<view class="btn downbtn">
							取消
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 我购买的 -->
		<view class="" v-if="sendorbuy==false">
			<view class="goods-cards">
				<!-- 商品卡片 -->
				<view class="card-item" v-for="(item,index) in buyBoxList" :key="index">
					<view class="card-top">
						<view class="info">
							<image :src="item.src" mode=""></image>
							<view class="name">
								{{item.user}}
							</view>
						</view>
						<view class="buyStatus">
							{{buystatus[1]}}
						</view>
						<view class="payStatus" v-if="false">
							待支付
						</view>

					</view>
					<view class="card-bottom">
						<!-- 卡片左侧 -->
						<view class="card-lef">
							<image class="card-img" :src="item.image" mode="aspectFill" />
						</view>
						<!-- 卡片右侧 -->
						<view class="card-rig">
							<view class="good-name">
								{{item.boxName}}
							</view>
							<view class="good-details">
								<view class="btn delbtn">
									删除订单
								</view>
							</view>
							<view class="good-details">
								<view class="goodstatus">
									<text>￥{{pricerange.preprice}}</text>
								</view>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
		<!-- 底部按钮 -->
		<view class="Bottombtn">
			<view class="bottombtn" v-if="edit">
				<template v-if="allStatus">
					<view class="bottom-lef" @click="changeAll">
						<uni-icons :type="false?'checkbox-filled':'circle'" size="26" :color="false?'#FF7803':'#D0D0D0'"
							class="way-right">
						</uni-icons>
						<text style="color: #333;margin-left: 8rpx;">全选</text>
						<view class="haveChoose">
							<text>已选：</text>
							<text>
								6
							</text>
						</view>
					</view>

				</template>
				<template v-else>
					<view class="bottom-lef">
						<uni-icons :type="false?'checkbox-filled':'circle'" size="26" :color="false?'#FF7803':'#D0D0D0'"
							class="way-right">
						</uni-icons>
						<text style="color: #333;margin-left: 8rpx;">全选</text>
						<view class="haveChoose">
							<text>已选：</text>
							<text>
								6
							</text>
						</view>
					</view>
				</template>
				<view class="bottom-mid" v-if="isedit">
					<view class="toexchange btn" @click="goToPage('/pages/good/order')">
						确认下架
					</view>
				</view>
				<view class="bottom-mid" v-if="iseditSec">
					<view class="toexchange btn" @click="goToPage('/pages/good/order')">
						批量删除
					</view>
				</view>
				<view class="bottom-mid" v-if="iseditThi">
					<view class="toexchange btn downbtn minbtn" @click="goToPage('/pages/good/order')">
						批量取消
					</view>
					<view class="toexchange btn minbtn" @click="goToPage('/pages/good/order')">
						批量上架
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				buystatus: ['待支付', '已完成', '已取消'], //我的购买-购买状态
				allStatus: false, //是否可全选
				edit: false,
				// 批量操作发布中
				isedit: false,
				// 批量操作已成交
				iseditSec: false,
				// 批量操作已下架
				iseditThi: false,
				fixedToptip: false,
				sendorbuy: true,
				current: 0,
				// 价格区间
				pricerange: {
					preprice: '30.36',
					endprice: '30.36'
				},
				joinnum: 3,
				activityBoxList: [{
					image: this.imagesUrl('hug.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('hug.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('hug.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('hug.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('hug.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, ],
				buyBoxList: [{
					image: this.imagesUrl('sell-water.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('sell-water.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('sell-water.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('sell-water.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, {
					image: this.imagesUrl('sell-water.png'),
					boxName: "盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称盲盒名称",
					chance: 20,
					price: 100,
					boxStatus: 1,
					name: '30.36',
					year: '2025/01/29',
					time: '18:02',
					user: '昌晶莹昌昌晶莹昌昌晶莹昌',
					src: this.imagesUrl('people.png'),
					buyordown: true,

				}, ],
				kinds: [{
					name: '发布中',
				}, {
					name: '已成交',
				}, {
					name: '已下架'
				}],
				buykinds: [{
					name: '全部',
				}, {
					name: '待支付',
				}, {
					name: '已完成'
				}, {
					name: '已取消'
				}],
				fixedTop: false,

			}
		},
		methods: {
			// 批量操作
			operateAll() {
				this.edit = !this.edit
				if (this.current === 0) {
					this.isedit = !this.isedit
				} else if (this.current === 1) {
					this.iseditSec = !this.iseditSec
				} else if (this.current === 2) {
					this.iseditThi = !this.iseditThi
				}
			},
			change(index) {
				this.edit = false
				this.isedit = false
				this.iseditSec = false
				this.iseditThi = false
				this.current = index.index;
				//如报错则用this.current = index.index;代替上面这句
			},
			sendor() {
				this.sendorbuy = true
			},
			buyor() {
				this.sendorbuy = false
			},
		},

		computed: {
			systemHeight() {
				return uni.getSystemInfoSync().windowTop
			}
		}
	}
</script>
<style>
	page {
		background-color: #fff;
	}
</style>
<style lang="scss" scoped>
	// 吸顶
	.fixedToptip {
		position: fixed;
		/* #ifdef H5 */
		top: 152rpx;
		/* #endif */
		// 在微信小程序 top值为0
		/* #ifdef MP-WEIXIN */
		top: 64rpx;
		/* #endif */
		z-index: 99;
		background-color: #fff;
	}

	.mysell {
		padding-bottom: constant(safe-area-inset-bottom);
		padding-bottom: env(safe-area-inset-bottom);

		.fixedTop {
			position: fixed;
			top: 88rpx;
			// 在微信小程序 top值为0
			/* #ifdef MP-WEIXIN */
			top: 0;
			/* #endif */

			z-index: 99;
			background-color: #fff;
		}

		.back {
			width: 750rpx;
			height: 64rpx;
			background-color: #ffffff;


			.sendorbuy {
				width: 690rpx;
				height: 64rpx;
				background-color: #f8f8f8;
				margin: 0 auto;
				/* #ifdef APP-PLUS */
				margin-top: 32rpx;
				/* #endif */
				border-radius: 44rpx;
				display: flex;
				justify-content: space-around;
				align-items: center;

				.mysend {
					width: 338rpx;
					height: 56rpx;
					border-radius: 44rpx;
					text-align: center;
					line-height: 56rpx;
					color: #999999;
				}

				.mybuy {
					width: 338rpx;
					height: 56rpx;
					border-radius: 44rpx;
					// background-color: #ffffff;
					text-align: center;
					line-height: 56rpx;
					color: #999999;
				}

				.active {
					background-color: #ffffff;
					color: #333333;
				}
			}
		}

		.tabs {
			height: 110rpx;
			width: 750rpx;
			display: flex;
			align-items: center;

			/deep/ .u-tabs__wrapper__nav__item {
				padding: 0 30rpx;
			}

			/deep/ .u-tabs__wrapper__nav__item__text {
				font-size: 28rpx;
			}

			.controlall {
				font-size: 24rpx;
				font-weight: 500;
				margin-right: 30rpx;
				position: absolute;
				right: 0;
			}
		}

		.buytabs {
			height: 110rpx;
			display: flex;
			align-items: center;

			.controlall {
				font-size: 24rpx;
				font-weight: 500;
				margin-right: 30rpx;
				position: absolute;
				right: 0;
			}
		}

		.goods-cards {
			background-color: #f8f8f8;

			.card-item {
				margin: 0rpx 30rpx;
				padding: 32rpx 0;
				border-bottom: 0.5px solid rgba(0, 0, 0, 0.1);
				color: #333333;
				width: 690rpx;
				background-color: #f8f8f8;
				display: flex;
				flex-direction: column;
				justify-content: space-between;
				align-items: center;
				position: relative;

				.card-top {
					display: flex;
					justify-content: space-between;
					align-items: center;
					width: 690rpx;
					font-size: 24rpx;
					margin-bottom: 16rpx;

					image {
						width: 48rpx;
						height: 48rpx;
					}

					.info {
						color: #999999;
						display: flex;
						align-items: center;
						justify-content: space-between;

						.name {
							width: 120rpx;
							margin-left: 16rpx;
							font-weight: normal;
							line-height: 30rpx;
							letter-spacing: 0.64rpx;
							text-overflow: ellipsis;
							white-space: nowrap;
							overflow: hidden;
						}
					}

					.buyStatus {
						font-size: 28rpx;
						font-weight: normal;
						text-align: right;
						color: #999999;
					}

					.payStatus {
						font-size: 28rpx;
						font-weight: normal;
						text-align: right;
						color: #FF7803;
					}
				}

				.card-bottom {
					display: flex;

					align-items: center;
					width: 690rpx;

					.rig {
						margin-right: 4rpx;
					}

					.card-lef {
						width: 156rpx;
						height: 156rpx;
						overflow: hidden;

						.card-img {
							width: 100%;
							height: 100%;
						}
					}

					.card-rig {
						margin-left: 30rpx;
						height: 156rpx;
						display: flex;
						flex-direction: column;
						position: relative;

						.good-name {
							font-size: 28rpx;
							height: 44rpx;
							width: 504rpx;
							line-height: 44rpx;
							letter-spacing: 0.64px;
							text-overflow: ellipsis;
							white-space: nowrap;
							overflow: hidden;
						}

						.good-checked {
							width: 460rpx;
						}
					}
				}

				.good-details {
					margin-top: 32rpx;
					display: flex;
					justify-content: space-between;
					align-item: center;
					text-align: right;
					line-height: 20rpx;

					.goodstatus {
						display: flex;
						align-items: center;
						text-align: center;
						font-size: 32rpx;
						font-weight: 500;
						line-height: 32rpx;
						color: #333333;

						.priceinp {
							font-size: 24rpx;
							margin-left: 16rpx;
							width: 172rpx;
							height: 56rpx;
							background-color: #fff;
							border-radius: 28rpx;
						}
					}

					.btn {
						font-size: 24rpx;
						font-weight: 500;
						position: absolute;
						right: 0;
						bottom: 0;
						width: 112rpx;
						height: 48rpx;
						line-height: 46rpx;
						border: 1px solid #FF7803;
						box-sizing: border-box;
						border-radius: 32rpx;
						background: #FF7803;
						color: #fff;
						text-align: center;
					}

					.delbtn {
						width: 160rpx;
						height: 48rpx;
						font-size: 24rpx;
						color: #333333;
						background: #fff;
						box-sizing: border-box;
						/* 辅助性-D0D0D0 */
						border: 1px solid #D0D0D0;
					}

					.specBtn {
						position: absolute;
						bottom: 32rpx;
					}

					.downbtn {
						position: absolute;
						right: 128rpx;
						bottom: 32rpx;
						border: 1px solid #FF7803;
						line-height: 46rpx;
						box-sizing: border-box;
						color: #FF7803;
						background: #fff;
					}


				}
			}

			.card-long {
				height: 204rpx;
			}
		}

		.Bottombtn {
			padding-bottom: constant(safe-area-inset-bottom);
			padding-bottom: env(safe-area-inset-bottom);
			position: fixed;
			bottom: 0;
			background-color: #ffffff;
			color: rgba(102, 102, 102, 0.66);
			z-index: 10200;

			.bottombtn {
				width: 750rpx;
				height: 120rpx;
				background-color: white;
				display: flex;
				justify-content: space-between;
				align-items: center;

				.bottom-lef {
					margin-left: 40rpx;
					display: flex;
					justify-content: space-between;
					align-items: center;

					.haveChoose {
						font-size: 24rpx;
						margin-left: 40rpx;
					}
				}

				.bottom-mid {
					display: flex;
					align-items: center;

				}

				.btn {
					height: 76rpx;
					border-radius: 44rpx;
					color: white;
					text-align: center;
					line-height: 76rpx;
					font-size: 28rpx;
					font-weight: 500;
				}

				.toexchange {
					margin-right: 30rpx;
					background: linear-gradient(270deg, #FC4C14 0%, #FD7303 100%);
					width: 240rpx;
				}

				.downbtn {
					border: 1px solid #FF7803;
					box-sizing: border-box;
					color: #FF7803;
					background: #fff;
				}

				.minbtn {
					width: 176rpx;
				}
			}
		}
	}
</style>